/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.spring66.tutorial.web.controller;

import com.spring66.tutorial.model.AppUser;
import com.spring66.tutorial.service.AppUserService;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.servlet.mvc.SimpleFormController;

/**
 *
 * @author twinp
 */
public class UsrFormController extends SimpleFormController {

    private AppUserService appUserService;

    public UsrFormController() {
        setCommandClass(AppUser.class);
        setCommandName("usr");
    }

    @Override
    protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
    }

    @Override
    protected void doSubmitAction(Object command) throws Exception {
        AppUser usr = (AppUser) command;
        appUserService.createUser(usr);
    }

    /**
     * @return the usrService
     */
    public AppUserService getAppUserService() {
        return appUserService;
    }

    /**
     * @param usrService the usrService to set
     */
    public void setAppUserService(AppUserService appUserService) {
        this.appUserService = appUserService;
    }
}
